<?php
defined("_ALLOW") or die ("Access denied");
?>
<?php
if (isset($_REQUEST['submit']) && isset($_SESSION['randomregister'])) {
	$sid = $_REQUEST['sid'];
	$email = $_REQUEST['emailregister'];
	if ($_SESSION['randomregister'] != "" && $sid == $_SESSION['randomregister']) {
		unset($_SESSION['randomregister']);
		include_once("class/cmkuser.php");
		global $objmkuser;
		$tobjmkuser = $objmkuser->Doc("$email");
		if ($tobjmkuser == null) {
			$objmkuser->email = $email;
			$objmkuser->password = $_REQUEST['passwordregister'];
			$objmkuser->hoten = $_REQUEST['hoten'];
			$objmkuser->dienthoai = $_REQUEST['dienthoai'];
			$objmkuser->diachi = $_REQUEST['diachi'];
			$objmkuser->congty = $_REQUEST['congty'];
			$objmkuser->website = $_REQUEST['website'];
			$objmkuser->sid = $sid;
			$objmkuser->Register();
			$message = '
			<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td colspan="2">Xin ch&acirc;n th&agrave;nh c&#7843;m &#417;n b&#7841;n &#273;&atilde; tham gia <a href="http://www.diaoc24g.vn" target="_blank">www.diaoc24g.vn</a> - Website chia s&#7867; th&ocirc;ng tin th&#432;&#417;ng m&#7841;i &#273;i&#7879;n t&#7917;.</td>
  </tr>
  <tr>
    <td colspan="2">D&#432;&#7899;i &#273;&acirc;y l&agrave; th&ocirc;ng tin b&#7841;n &#273;&atilde; &#273;&#259;ng k&yacute; tr&ecirc;n diaoc24g.vn</td>
  </tr>
  <tr>
    <td width="16%" >Email</td>
    <td width="84%">'.$objmkuser->email.'</td>
  </tr>
  <tr>
    <td>Password</td>
    <td>'.$objmkuser->password.'</td>
  </tr>
  <tr>
    <td>H&#7885; t&ecirc;n</td>
    <td>'.$objmkuser->hoten.'</td>
  </tr>
  <tr>
    <td>&#272;i&#7879;n th&#7885;ai</td>
    <td>'.$objmkuser->dienthoai.'</td>
  </tr>
  <tr>
    <td>&#272;&#7883;a ch&#7881;</td>
    <td>'.$objmkuser->diachi.'</td>
  </tr>
  <tr>
    <td>C&ocirc;ng ty</td>
    <td>'.$objmkuser->congty.'</td>
  </tr>
  <tr>
    <td>Website</td>
    <td>'.$objmkuser->website.'</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">Click v&agrave;o link d&#432;&#7899;i &#273;&acirc;y &#273;&#7875; k&iacute;ch ho&#7841;t t&agrave;i kho&#7843;n c&#7911;a b&#7841;n.<br />
    <a href="http://www.diaoc24g.vn/index.php?module=com_useractive&amp;emailactive='.$objmkuser->email.'&sidactive='.$objmkuser->sid.'" target="_blank">http://www.diaoc24g.vn/index.php?module=com_useractive&amp;emailactive='.$objmkuser->email.'&sidactive='.$objmkuser->sid.'</a>
    </td>
  </tr>
</table>
			';
			/*$resultsendmail = mysendmail("support@mekongconnect.com", $objmkuser->email, "Kich hoat tai khoan mekongconnect.com", $message);
			if (!$resultsendmail) {
				global $csdl;
				$strsql = "DELETE mk_users WHERE email='" . $objmkuser->email . "'";
				$csdl->Xoa("mk_users", "email='" . $objmkuser->email . "'");
				echo "<span style='color:#ff0000;'>Đăng ký thất bại. Vui lòng kiểm tra lại email.</span>";
				include_once("register.php");
			}
			else {*/
			?>
			<div style="font-family:Tahoma; font-size:12px; color:#CC0000; font-weight:bold; text-align:center;">
			<?php
				echo "<strong>Bạn đã đăng ký thành công</strong><br />Xin chân thành cảm ơn bạn đã tham gia diaoc24g.vn";
			?>
			</div>
			<?php
			//}
		}
		else {
			if (isset($_SESSION['username']))
				if ($_SESSION['username'] == $email) {//cap nhat thong tin
					$tobjmkuser->password = $_REQUEST['passwordregister'];
					$tobjmkuser->hoten = $_REQUEST['hoten'];
					$tobjmkuser->dienthoai = $_REQUEST['dienthoai'];
					$tobjmkuser->diachi = $_REQUEST['diachi'];
					$tobjmkuser->congty = $_REQUEST['congty'];
					$tobjmkuser->website = $_REQUEST['website'];
					$tobjmkuser->Ghi();
					echo "<span style='color:#0000ff;'>Cập nhật thành công.</span>";
					$_SESSION['hoten'] = $tobjmkuser->hoten;
					include_once("register.php");
				}
				else
					mosRedirect("index.php");
			else {//Dang ky user da ton tai. Dang ky email khac
				echo "<span style='color:#ff0000;'>Email đã có người đăng ký trước. Xin vui lòng chọn email khác.</span>";
				include_once("register.php");
			}
		}
	}
	else {
		echo "<span style='color:#ff0000;'>Mã xác nhận không hợp lệ.</span>";
		include_once("register.php");
	}
}
else {
include_once("register.php");
}
?>